package SEApp.dialogs
{
	import SEApp.dialogs.se_alert;
	import SEApp.se_app;
	
	import UIFree.controls.uif_input;
	import UIFree.uif_app;
	import UIFree.uif_component;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	public class se_inputDialog extends se_alert {
		private var _input: uif_input;
		public function se_inputDialog(parent:uif_component, message:String, okFunc:Function=null) {
			super(parent, message, okFunc, true);
		}
		
		override protected function createDialogComponents():void {
			super.createDialogComponents();
			var inner: Rectangle = getInner();
			_input = new uif_input(this, inner.x, 0, inner.width, 22, 'minput');
		}
		
		override protected function resizeFromText(): Rectangle {
			var rect: Rectangle = super.resizeFromText();
			_input.y = _desc.y + _desc.height + 5;
			rect.height += 30;
			height += 30;
			return rect;
		}
		
		public static function run(title: String, message: String, doRelease: Function, doClose: Function=null): void {
			var dialog: se_inputDialog = new se_inputDialog((uif_app.instance() as se_app).dialogLayer, message, function(): void {
				doRelease(dialog._input.text);
			});
			
			if (doClose != null) dialog.addEvent(Event.CLOSE, doClose);
			dialog.title.text = title;
			dialog.show();
		} 		
	}
}